Skip to content

adding the JsonShapeSerializer#3842

Open
pulimsr wants to merge 9 commits into
mainfrom
schema-serde
Open

adding the JsonShapeSerializer#3842
pulimsr wants to merge 9 commits into
mainfrom
schema-serde

Conversation

@pulimsr

@pulimsr pulimsr commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Adding the implementation for JsonShapeSerializer

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pulimsr pulimsr marked this pull request as ready for review June 9, 2026 18:45
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/include/smithy/client/schema/JsonShapeSerializer.h Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/source/smithy/client/schema/JsonShapeSerializer.cpp Outdated
Comment thread src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h Outdated
#include <memory>
#include <aws/core/utils/memory/AWSMemory.h>

#include "aws/core/client/AWSError.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit use: #include <aws/core/client/AWSError.h>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

private:
Aws::String m_buf;
int m_depth = 0;
Aws::Array<bool, MAX_DEPTH> m_needsComma{};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran clang format

Comment thread src/aws-cpp-sdk-core/CMakeLists.txt Outdated

add_library(${PROJECT_NAME} ${AWS_NATIVE_SDK_SRC})
add_library(${PROJECT_NAME} ${AWS_NATIVE_SDK_SRC}
include/smithy/client/schema/ShapeSerializer.h

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt the right thing to do, look at how we do this for other headers in the smithy directory

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this

public:
static void WriteQuotedString(Aws::String& buf, const Aws::String& value);
private:
static const bool NEEDS_ESCAPE[128];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if these are static const, why do they need to be static in the WriteQuotedString class? seems like it would be a better fit for them to be a in anonymous namespace in JsonWriteUtils.cpp. also, again, prefer std::array to c style arrays

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to anonymous namespace in .cpp, using Aws::Array and switch statement

ShapeType GetType() const { return m_type; }
const char* GetId() const { return m_id; }
const char* GetMemberName() const { return m_memberName; }
const Aws::String& GetMemberName() const { return m_memberName; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of sketched by Aws::String&, it could possibly create lifetime issues however, the way you use it wont. i would err on caution and return Aws::String because likely member name will be short string optimized and removes the lifetime issue not a NEEDS to happen but something to think about.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to Aws::String


const char JsonWriteUtils::HEX[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

const bool JsonWriteUtils::NEEDS_ESCAPE[128] = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we create a table for both needs escape and then the escape value, im not opposed to this however might make more sense just to copy the switch statement from cjson. correct me if im wrong but you more or less could just do that loop in our code, and avoid the size penalty (albeit small) on the translation unit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants